<?php
class WebsiteAction extends CommonAction {
	
	
	
	
	public function add(){
		
		if(empty($_REQUEST ['id'])){
			$this->assign('codeList',$this->getModuleList(0, $this->getActionName())) ;
		}else{
			$condition['id'] = $_REQUEST ['id'] ;
			//dump($this->CommonSimplequery($condition,$this->getActionName(),0));
			$this->assign('codeList',$this->CommonSimplequery($condition,'viewwebsite',0));
			$this->assign('id',$_REQUEST ['id']) ;
			$this->assign('webSiteVo',$this->CommonSimplequery($condition,$this->getActionName(),1));
			
		}
		$this->display ();
	}
	
	/**
	 * 
	 * 保存导航说明信息
	 */
	public function saveWebsite(){
		
		if(empty($_REQUEST ['id'])){
			$model = M ( $this->getActionName() );		
			$data ['createdate'] = date('Y-m-d H:i:s',time());
			$data ['statusdate'] = date('Y-m-d H:i:s',time());
			$data ['code'] = $_REQUEST['code'] ;
			$data ['status'] = $_REQUEST['status'] ;
			$data ['summary'] = $_REQUEST['summary'] ;
			$data ['content'] = stripslashes($_REQUEST['editorcontent']) ;
			$save_result = $model->add($data) ;		
			$this->resultHandle($save_result,"新增网站信息成功！","新增网站信息失败！");
		}else{
			$model = M ( $this->getActionName() );			
			$data ['statusdate'] = date('Y-m-d H:i:s',time());
			$data ['code'] = $_REQUEST['code'] ;
			$data ['status'] = $_REQUEST['status'] ;
			$data ['content'] = stripslashes($_REQUEST['editorcontent']) ;
			$condition['id'] = $_REQUEST ['id'] ;
			$update_result = $model->where($condition)->save($data) ;		
			$this->resultHandle($update_result,"修改网站信息成功！","修改网站信息失败！");
		}
	}
	
	/**
	 * 修改状态 
	 * 
	 */
	public function statusHandle(){		
		$model = D( $this->getActionName() );		
		$id = $_REQUEST ['id'];		
		$condition['id'] = $id ;
		$vo = $this->CommonSimplequery($condition, $this->getActionName(),1);
		$data['status'];
		if($vo['status'] == 1){
			$data['status'] = 0  ;
		}else{
			$data['status'] = 1  ;
		}
   	    $this->resultHandle($model->where($condition)->save($data),"产品类型状态修改成功！","产品类型状态修改失败！") ;

	}

}
?>